package com.douziit.meilianoa.base.exception;



import com.douziit.meilianoa.base.enums.ResponseCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 该异常主要用于在Service层里面做抛出错误提示
 *
 * @author MrShun
 * @version 1.0
 * @Date 2017-08-24
 */
public class TipException extends RuntimeException {

    private static Logger LOG = LoggerFactory.getLogger(TipException.class);

    private ResponseCode resp;

    private Integer code;

    public TipException() {
        super();
    }

    public TipException(String message) {
        super(message);
    }

    public TipException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public TipException(ResponseCode responseCode) {
        super(responseCode.getMsg());
        this.resp = responseCode;
    }

    public ResponseCode getResponseCode() {
        return resp;
    }

    public Integer getCode() {
        return code;
    }

    public TipException(String message, Throwable cause) {
        super(message, cause);
    }

    public TipException(Throwable cause) {
        super(cause);
        StackTraceElement stackTraceElement = getStackTrace()[0];
        LOG.info("提示：" + stackTraceElement.toString() + " -> " + getMessage());
    }
}
